﻿using UnityEngine;
using System.Collections;

public class MainUI : MonoBehaviour {

    // Use this for initialization
    void Start ( ) {
        NetHandle.Instance.MainUiReq(MainUIReturn);      
    }

    #region 响应UGUI事件

    public void OnEnterRoom ( ) {
        NetHandle.Instance.EnterRoomReq(EnterRoomReturn);
    }

    #endregion 响应UGUI事件   

    #region 服务器响应

    private void MainUIReturn (ActionResult action) {
        Debug.Log(string.Format("Pid={0}", action.Get<string>("Pid")));
        Debug.Log(string.Format("HeadIcon={0}", action.Get<string>("HeadIcon")));
        Debug.Log(string.Format("NickName={0}", action.Get<string>("NickName")));
        Debug.Log(string.Format("GameCoin={0}", action.Get<int>("GameCoin")));
        Debug.Log(string.Format("Gold={0}", action.Get<int>("Gold")));
        Debug.Log(string.Format("VipLv={0}", action.Get<int>("VipLv")));
        Debug.Log(string.Format("WinNum={0}", action.Get<int>("WinNum")));
        Debug.Log(string.Format("FailNum={0}", action.Get<int>("FailNum")));
        Debug.Log(string.Format("TitleName={0}", action.Get<string>("TitleName")));
        Debug.Log(string.Format("ScoreNum={0}", action.Get<int>("ScoreNum")));
        Debug.Log(string.Format("WinRate={0}", action.Get<int>("WinRate")));

        Debug.Log(string.Format("RoomId={0}", action.Get<int>("RoomId")));
    }

    private void EnterRoomReturn (ActionResult actionResult) {
        Debug.Log("GameCoin = " + actionResult.Get<int>("GameCoin"));
        Application.LoadLevel("MainDesk");
    }

    #endregion 服务器响应

}
